import { useMapper } from "./useMapper";
import { mapState, createNamespacedHelpers } from "vuex";

export function useState(moduleName, mapper) {
  let mapFn = mapState;
  if (typeof moduleName === "string" && moduleName.length > 0) {
    mapFn = createNamespacedHelpers(moduleName).mapState;
  }else{
    mapper=moduleName
  }
  const storeState = useMapper(mapper, mapFn);
  return storeState;
}
